package com.ssh.action.petdiary;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.ssh.biz.IPetdiaryBiz;
import com.ssh.biz.IPetinfoBiz;
import com.ssh.entity.Petdiary;
import com.ssh.entity.Petinfo;
@Controller
@Scope("prototype")
public class WriteDairyAction extends ActionSupport{
	@Resource
	private IPetdiaryBiz iPetdiaryBiz;
	@Resource
	private IPetinfoBiz iPetinfoBiz;
	
	private Petdiary petdiary;
	private Petinfo petinfo;
	
	private int petId;
	
	
	public String execute()throws Exception{
		Map<String, Object> vcodeMap = ActionContext.getContext().getSession();
		Petinfo pet=(Petinfo)vcodeMap.get("pet");
		Petinfo petinfo = iPetinfoBiz.findPetByID(pet.getPetId());
		petdiary.setPetinfo(petinfo);
		iPetdiaryBiz.savePetdiary(petdiary);
		
		return "success";
		
	}
	

	public IPetdiaryBiz getiPetdiaryBiz() {
		return iPetdiaryBiz;
	}

	public void setiPetdiaryBiz(IPetdiaryBiz iPetdiaryBiz) {
		this.iPetdiaryBiz = iPetdiaryBiz;
	}

	public IPetinfoBiz getiPetinfoBiz() {
		return iPetinfoBiz;
	}

	public void setiPetinfoBiz(IPetinfoBiz iPetinfoBiz) {
		this.iPetinfoBiz = iPetinfoBiz;
	}

	public Petdiary getPetdiary() {
		return petdiary;
	}

	public void setPetdiary(Petdiary petdiary) {
		this.petdiary = petdiary;
	}

	public int getPetId() {
		return petId;
	}

	public void setPetId(int petId) {
		this.petId = petId;
	}


	public Petinfo getPetinfo() {
		return petinfo;
	}


	public void setPetinfo(Petinfo petinfo) {
		this.petinfo = petinfo;
	}
}
